<?php
if (!$strScreenName){$strScreenName = 'DisplayVendor';}

$strQueryName = 'qryAddVendor';
$strFormName = 'frmEnterVendor';

     if (($intVendorID) && (!$strReprocessing)) {
             include (MODULE . "/action/qrySelectVendor");
             $strTitle = "Update";
             $strButtonTitle = "update";
             $txtID = stripslashes($myrow["ID"]);
             $cboCommission = stripslashes($myrow["Commission"]);
             $cboTitle = stripslashes($myrow["Title"]);
             $txtCompanyName = stripslashes($myrow["CompanyName"]);
             $txtFirstName = stripslashes($myrow["FirstName"]);
             $txtSurname = stripslashes($myrow["Surname"]);
             $txtAddress1 = stripslashes($myrow["Address1"]);
             $txtAddress2 = stripslashes($myrow["Address2"]);
             $txtTown = stripslashes($myrow["Town"]);
             $txtCounty = stripslashes($myrow["County"]);
             $txtPostalCode = stripslashes($myrow["PostalCode"]);
             $txtCountry = stripslashes($myrow["Country"]);
             $txtPhone = stripslashes($myrow["Phone"]);
             $txtMobile = stripslashes($myrow["Mobile"]);
             $txtFax = stripslashes($myrow["Fax"]);
             $txtEmail = stripslashes($myrow["Email"]);
             $txtChequePayableTo = stripslashes($myrow["ChequePayableTo"]);
             $txtPassword = stripslashes($myrow["Password"]);
             $txtRegistrationDate = ReformatFromMySqlDate($myrow["RegistrationDate"]);
             $cboReferrer = stripslashes($myrow["Referrer"]);
             $txtLoginDate = ReformatFromMySqlDate($myrow["LoginDate"]);
         }else{
             $strTitle = "Enter";
             $strButtonTitle = "save";
             if($txtID){ $txtID = stripslashes(eregi_replace("\"", "&quot;", $txtID)); }
         	 if($cboCommission)
         	 { 
         	 	$cboCommission = stripslashes(eregi_replace("\"", "&quot;", $cboCommission)); 
         	 }else{
         	 	$cboCommission = 1;
         	 }
             if($cboTitle){ $cboTitle = stripslashes(eregi_replace("\"", "&quot;", $cboTitle)); }
             if($txtCompanyName){ $txtCompanyName = stripslashes(eregi_replace("\"", "&quot;", $txtCompanyName)); }
             if($txtFirstName){ $txtFirstName = stripslashes(eregi_replace("\"", "&quot;", $txtFirstName)); }
             if($txtSurname){ $txtSurname = stripslashes(eregi_replace("\"", "&quot;", $txtSurname)); }
             if($txtAddress1){ $txtAddress1 = stripslashes(eregi_replace("\"", "&quot;", $txtAddress1)); }
             if($txtAddress2){ $txtAddress2 = stripslashes(eregi_replace("\"", "&quot;", $txtAddress2)); }
             if($txtTown){ $txtTown = stripslashes(eregi_replace("\"", "&quot;", $txtTown)); }
             if($txtCounty){ $txtCounty = stripslashes(eregi_replace("\"", "&quot;", $txtCounty)); }
             if($txtPostalCode){ $txtPostalCode = stripslashes(eregi_replace("\"", "&quot;", $txtPostalCode)); }
             if($txtCountry){ $txtCountry = stripslashes(eregi_replace("\"", "&quot;", $txtCountry)); }
             if($txtPhone){ $txtPhone = stripslashes(eregi_replace("\"", "&quot;", $txtPhone)); }
             if($txtMobile){ $txtMobile = stripslashes(eregi_replace("\"", "&quot;", $txtMobile)); }
             if($txtFax){ $txtFax = stripslashes(eregi_replace("\"", "&quot;", $txtFax)); }
             if($txtEmail){ $txtEmail = stripslashes(eregi_replace("\"", "&quot;", $txtEmail)); }
             if($txtChequePayableTo){ $txtChequePayableTo = stripslashes(eregi_replace("\"", "&quot;", $txtChequePayableTo)); }
             if($txtPassword){ $txtPassword = stripslashes(eregi_replace("\"", "&quot;", $txtPassword)); }
             if($cboReferrer){ $txtReferrer = stripslashes(eregi_replace("\"", "&quot;", $txtReferrer)); }
     }
echo "
<tr>
     <td>
         <table  width='450' cellpadding='0' cellspacing='0' border='0' class='Normal' align='center'>
     <tr align='left'>
         <td align='left' colspan='2'>
             <H2>$strTitle Vendor</H2>
         </td>
     </tr>
";
// Upploaded = 0
echo (StartForm($strScreenName, "post", $strQueryName,array('intVendorID'=>$intVendorID,'strReprocessing'=>'True'),"","",$strFormName,"","return frmEnterVendor_onsubmit()"));
?>

     <tr>
         <td align='right' colspan='2'>
             <input type='image' src='./images/<?php echo $strButtonTitle ?>.gif' alt='<?php echo $strButtonTitle?>'>
         </td>
     </tr>

	<tr>
         <td align='right' colspan='1'>
             <b>Commission :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <?php CreateDropDown("cboCommission", "SELECT * FROM tblAuctionCommission ORDER BY 2", "", $cboCommission); ?>

		 </td>
     </tr>

     <tr>
         <td align='right' colspan='1'>
             <b>Contact Title :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <?php CreateDropDown("cboTitle", "SELECT * FROM tblTitle ORDER BY 2", "", $cboTitle); ?>

		 </td>
     </tr>

     <tr>
         <td align='right' colspan='1'>
             <b>Company :&nbsp;</b>
		</td>
         <td align='left' colspan='1'>
             <input type="text" name="txtCompanyName" value = "<?php echo $txtCompanyName?>" size= "50" maxlength="100">
         </td>
     </tr>

     <tr>
         <td align='right' colspan='1'>
             <b>First Name :&nbsp;</b>
		 </td>
         <td align='left' colspan='1'>
             <input type="text" name="txtFirstName" value = "<?php echo $txtFirstName?>" size= "40" maxlength="40">
         </td>
     </tr>

     <tr>
         <td align='right' colspan='1'>
             <b>Surname :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <input type="text" name="txtSurname" value = "<?php echo $txtSurname?>" size= "30" maxlength="30">
         </td>
     </tr>

     <tr>
         <td align='right' colspan='1'>
             <b>Address :&nbsp;</b>
		 </td>
         <td align='left' colspan='1'>
             <input type="text" name="txtAddress1" value = "<?php echo $txtAddress1 ?>" size= "60" maxlength="60">
         </td>
     </tr>

     <tr>
         <td align='right' colspan='1'>
             <b>&nbsp;</b>
		 </td>
         <td align='left' colspan='1'>
             <input type="text" name="txtAddress2" value = "<?php echo  $txtAddress2?>" size= "60" maxlength="60">
         </td>
     </tr>
<?php

//  Type                 10
//  atrributes           2
//  AllowZeroLength      False
//  Default Value        
//  Validate Rule        
//  Validate Text        City
//  SourceField          Town
//  Required             True
echo "
     <tr>
         <td align='right' colspan='1'>
             <b>Town/City :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <input type=\"text\" name=\"txtTown\" value = \"$txtTown\" size= \"30\" maxlength=\"30\">
         </td>
     </tr>
";

//  Type                 10
//  atrributes           2
//  AllowZeroLength      False
//  Default Value        
//  Validate Rule        
//  Validate Text        Region
//  SourceField          County
//  Required             True
echo "
     <tr>
         <td align='right' colspan='1'>
             <b>County :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <input type=\"text\" name=\"txtCounty\" value = \"$txtCounty\" size= \"25\" maxlength=\"25\">
         </td>
     </tr>
";

//  Type                 10
//  atrributes           2
//  AllowZeroLength      False
//  Default Value        
//  Validate Rule        
//  Validate Text        Postal Code
//  SourceField          PostalCode
//  Required             True
echo "
     <tr>
         <td align='right' colspan='1'>
             <b>Postal Code :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <input type=\"text\" name=\"txtPostalCode\" value = \"$txtPostalCode\" size= \"10\" maxlength=\"10\">
         </td>
     </tr>
";

//  Type                 4
//  atrributes           1
//  AllowZeroLength      False
//  Default Value        0
//  Validate Rule        
//  Validate Text        Country
//  SourceField          Country
//  Required             True
echo "
     <tr>
         <td align='right' colspan='1'>
             <b>Country :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <input type=\"text\" name=\"txtCountry\" value = \"$txtCountry\" size= \"4\" maxlength=\"4\">
         </td>
     </tr>
";

//  Type                 10
//  atrributes           2
//  AllowZeroLength      False
//  Default Value        
//  Validate Rule        
//  Validate Text        Phone
//  SourceField          Phone
//  Required             True
echo "
     <tr>
         <td align='right' colspan='1'>
             <b>Phone :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <input type=\"text\" name=\"txtPhone\" value = \"$txtPhone\" size= \"24\" maxlength=\"24\">
         </td>
     </tr>
";

//  Type                 10
//  atrributes           2
//  AllowZeroLength      True
//  Default Value        
//  Validate Rule        
//  Validate Text        Mobile
//  SourceField          Mobile
//  Required             False
echo "
     <tr>
         <td align='right' colspan='1'>
             <b>Mobile :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <input type=\"text\" name=\"txtMobile\" value = \"$txtMobile\" size= \"24\" maxlength=\"24\">
         </td>
     </tr>
";

//  Type                 10
//  atrributes           2
//  AllowZeroLength      False
//  Default Value        
//  Validate Rule        
//  Validate Text        Fax
//  SourceField          Fax
//  Required             False
echo "
     <tr>
         <td align='right' colspan='1'>
             <b>Fax :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
           <input type=\"text\" name=\"txtFax\" value = \"$txtFax\" size= \"24\" maxlength=\"24\">
         </td>
     </tr>
";

//  Type                 10
//  atrributes           2
//  AllowZeroLength      False
//  Default Value        
//  Validate Rule        
//  Validate Text        Email
//  SourceField          Email
//  Required             False
echo "
     <tr>
         <td align='left' colspan='2'>
             <b>Email :&nbsp;</b><br/>
             <div align='right'>
             <input type=\"text\" name=\"txtEmail\" value = \"$txtEmail\" size= \"80\" maxlength=\"100\"></div>
         </td>
     </tr>
";

//  Type                 10
//  atrributes           2
//  AllowZeroLength      True
//  Default Value        
//  Validate Rule        
//  Validate Text        Cheque Payable To
//  SourceField          ChequePayableTo
//  Required             True
echo "
     <tr>
         <td align='left' colspan='2'>
             <b>Cheque Payable To :&nbsp;</b><br/>
             <div align='right'>
             <input type=\"text\" name=\"txtChequePayableTo\" value = \"$txtChequePayableTo\" size= \"75\" maxlength=\"75\"></div>
         </td>
     </tr>
";



?>
     <tr>
         <td align='right' colspan='1'>
             <b>Referrer :&nbsp;</b>
         </td>
         <td align='left' colspan='1'>
		 <?php
           	CreateDropDown("cboReferrer", "SELECT * FROM tblReferrer ORDER BY 2", "", $cboReferrer);
		
				if($_SESSION['sesUserType'] == "staff"){
             		echo "<a href='".ScreenURL("EnterReferrer")."' target='_blank'>+</a>";
				}
			?>
         </td>
     </tr>
<?



echo "
     <tr>
         <td align='right' colspan='2'>
             <input type='image' src='./images/$strButtonTitle.gif' alt='$strButtonTitle'>
         </td>
     </tr>
         </table
     </form>
     </td>
 </tr>
";
     //$strListAll = "true";
       //include (MODULE . "/screen/ListVendor");
?>
<script language="JavaScript">
<!--
function frmEnterVendor_onsubmit() 
{


     if(document.frmEnterVendor.txtFirstName.value == "") {
         alert("Please enter First Name");
         document.frmEnterVendor.txtFirstName.focus();
         document.frmEnterVendor.txtFirstName.select();
         return(false);
     }

     if(document.frmEnterVendor.txtSurname.value == "") {
         alert("Please enter Surname");
         document.frmEnterVendor.txtSurname.focus();
         document.frmEnterVendor.txtSurname.select();
         return(false);
     }

     if(document.frmEnterVendor.txtAddress1.value == "") {
         alert("Please enter Address1");
         document.frmEnterVendor.txtAddress1.focus();
         document.frmEnterVendor.txtAddress1.select();
         return(false);
     }

     if(document.frmEnterVendor.txtTown.value == "") {
         alert("Please enter City");
         document.frmEnterVendor.txtTown.focus();
         document.frmEnterVendor.txtTown.select();
         return(false);
     }

     if(document.frmEnterVendor.txtCounty.value == "") {
         alert("Please enter Region");
         document.frmEnterVendor.txtCounty.focus();
         document.frmEnterVendor.txtCounty.select();
         return(false);
     }

     if(document.frmEnterVendor.txtPostalCode.value == "") {
         alert("Please enter Postal Code");
         document.frmEnterVendor.txtPostalCode.focus();
         document.frmEnterVendor.txtPostalCode.select();
         return(false);
     }

     if(document.frmEnterVendor.txtCountry.value == "") {
         document.frmEnterVendor.txtCountry.value = "202";
     }

     if(document.frmEnterVendor.txtPhone.value == "") {
         alert("Please enter Phone");
         document.frmEnterVendor.txtPhone.focus();
         document.frmEnterVendor.txtPhone.select();
         return(false);
     }

     if(document.frmEnterVendor.txtChequePayableTo.value == "") {
         alert("Please enter Cheque Payable To");
         document.frmEnterVendor.txtChequePayableTo.focus();
         document.frmEnterVendor.txtChequePayableTo.select();
         return(false);
     }

     if(document.frmEnterVendor.txtPassword.value == "") {
         alert("Please enter Password");
         document.frmEnterVendor.txtPassword.focus();
         document.frmEnterVendor.txtPassword.select();
         return(false);
     }


}
// -->
</script>
